import request from '@/utils/request';

export async function getCategoryList() {
    return request({
        url: '/api/v1/backend/category',
        method: 'get'
    });
}

export async function addCategory(data) {
    return request({
        url: '/api/v1/backend/category',
        method: 'post',
        data
    });
}

export async function updateCategory(data) {
    return request({
        url: '/api/v1/backend/category',
        method: 'put',
        data
    });
}

export async function deleteCategory(id) {
    return request({
        url: '/api/v1/backend/category/' + id,
        method: 'delete'
    });
}

export async function getCategory(id) {
    return request({
        url: '/api/v1/backend/category/' + id,
        method: 'get'
    });
}

// 栏目树
export async function getCategoryTree() {
    return request({
        url: '/api/v1/backend/category/tree',
        method: 'get'
    });
}

export async function categorySwitch(data) {
    return request({
        url: '/api/v1/backend/category/switch',
        method: 'get',
        params: data
    });
}

export async function categoryBatch(data) {
    return request({
        url: '/api/v1/backend/category/batch',
        method: 'post',
        data
    });
}
